package com.service.impl;

import com.entity.User;
import com.exception.ServiceException;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.BackModifyMapper;
import com.service.BackModifyService;
import com.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BackModifyServiceImpl implements BackModifyService {

@Autowired
    BackModifyMapper backModifyMapper;

    @Override
    public PageInfo<User> selAllPage(int pageNo, PageVo pageVo) throws ServiceException {
        PageHelper.startPage(pageNo, 2);
        List<User> list = backModifyMapper.findAllUsers(pageVo);
        if (null == list) {
            throw new ServiceException("没有记录...");
        }
        return new PageInfo<User>(list);
    }

    @Override
    public User selUserById(int id) throws ServiceException {
        return backModifyMapper.findUserById(id);
    }

    @Override
    public int updateUserInfoS(User user) throws ServiceException {
        return backModifyMapper.updateUserInfoM(user);
    }
}
